PTL 1 includes selection means for selecting one of a plurality of detection means based on a congestion degree determined by determination means, and count means for counting the number of subjects included in a frame image acquired by acquisition means based on the detection result detected from the frame image by using detection means selected by the selection means. By doing this, even in a case where a congestion degree is high and the subject is easily superimposed on the subject, it is possible to detect the subjects with high precision, and it is possible to count the number of subjects.